<?php
	ob_start();
	session_start();

	function __autoload($class_name) {
		include './'.$class_name . '.php';
	}
	$result = array();
	$isGiftWrap=$_GET['isGiftWrap'];
	$isGiftWrap = stripslashes($isGiftWrap);
	$isGiftWrap = mysql_real_escape_string($isGiftWrap);
	$status = true;
	
	$cart = NULL;
	if(!isset($_SESSION['cart']) || sizeof($_SESSION['cart']->getOrderList()) <= 0){
		$result['#success'] = false;
		$status = false;
	}else {
		$cart = $_SESSION['cart'];
	}
	
	if(!$status || ($isGiftWrap!= 'true' && $isGiftWrap !='false')) {
		$status = false;
	}
	if ($status){
		$cart->setGift($isGiftWrap=='true' ? true :false);
		$result['#success'] = true;
	} else {
		$result['#success'] = false;
	}
	if($status){
		header("Location: shoppingcart.php");
	} else {
		echo json_encode($result);
	}
	ob_end_flush();
?>